#ifndef __MY_CRITICALSECTION_H__
#define __MY_CRITICALSECTION_H__

#include <mutex>
#include "pthread.h"
#include <iostream>

class CMyCriticalSection
{
public:
    CMyCriticalSection()
    {
        ::pthread_mutex_init(&m_mutex,NULL);
    }
    ~CMyCriticalSection()
    {
        ::pthread_mutex_destroy(&m_mutex);
    }

    // Acquire the critical section
    void Enter()
    {
        ::pthread_mutex_lock(&m_mutex);
    }
    // Release the critical section
    void Leave()
    {
        ::pthread_mutex_unlock(&m_mutex);
    }
protected:
    mutable pthread_mutex_t m_mutex;
};

#endif
